﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/2/2009
 * Time: 3:32 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of PositionForm.
	/// </summary>
	public partial class PositionForm : BaseForm
	{
		public PositionForm() : this(new Position())
		{
			
		}
		
		public PositionForm(Position p)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = p;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			Position p = Model as Position;
			textBoxName.Text = p.Name;
			checkBoxInactive.Checked = p.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Position p = Model as Position;
			p.Name = textBoxName.Text;
			p.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdatePosition(p);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
